#include<bits/stdc++.h>
using namespace std;
long long T, n, m, L, V, d[100005], v[100005], a[100005], p[100005], cnt, now, ans;
bool flag, in[100005], light[1000005];
vector<long long> st[1000005];
struct speedHigh{
    long long l, r;
}s[100005];
bool f(long long l, long long r){
    if (l>r)return false;
    long long *i = lower_bound(p, p+m, r);
    if (*i==r)return true;
    if (i == p)return false;
    return *(--i)>=l;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin>>T;
    while(T--){
        memset(light, 0, sizeof(light));
        cin>>n>>m>>L>>V;
        cnt = 0;
        for (int i=0;i<n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for (int i=0;i<m;i++){
            cin>>p[i];
            light[p[i]] = true;
        }
        for (int i=0;i<n;i++){
            if (v[i]>V&&a[i]>=0){
                s[cnt].l = d[i];
                s[cnt].r = L;
                if (f(s[cnt].l, s[cnt].r))cnt++;
            }
            else if (a[i]>0){
                s[cnt].l = (V*V-v[i]*v[i])/(2*a[i])+1;
                s[cnt].r = L;
                if (f(s[cnt].l, s[cnt].r))cnt++;
            }
            else if (a[i]<0){
                if (v[i]>V){
                    s[cnt].l = d[i];
                    if ((V*V-v[i]*v[i])%(2*a[i])==0)s[cnt].r = (v[i]*v[i]-V*V)/(-2*a[i])-1;
                    else s[cnt].r = (v[i]*v[i]-V*V)/(-2*a[i]);
                    s[cnt].r += d[i];
                    if (f(s[cnt].l, s[cnt].r))cnt++;
                }
            }
        }
        cout<<cnt<<' ';
        for (int i=0;i<cnt;i++){
            st[s[i].l].push_back(i);
            st[s[i].r+1].push_back(i);
        }
        now = -1;
        ans = 0;
        memset(in, 0, sizeof(in));
        flag = false;
        for (int i=1;i<=L;i++){
            if (st[i].size()){
                for (int j=0;j<st[i].size();j++){
                    if (in[st[i][j]]){
                        if (now != -1){
                            ans++;
                        }
                        now = -1;
                        in[st[i][j]] = false;
                    }
                    else{
                        flag = true;
                        in[st[i][j]] = true;
                    }
                }
            }
            if (light[i]){
                if (flag){
                    now = i;
                    flag = false;
                }
            }
        }
        if (now != -1)ans++;
        cout<<m-ans<<endl;
        for (int i=1;i<=L+1;i++){
            st[i].clear();
        }
    }
}
